package com.example.dict.db;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class DBOpenHelper extends SQLiteOpenHelper {
    public DBOpenHelper(@Nullable Context context) {
        super(context,"dict.db",null,1);
    }




    @Override
    public void onCreate(SQLiteDatabase db) {

        String sql = "create table PYWORD(_id integer primary key autoincrement,id varchar(20),zi varchar(4) unique not null," +
                "py varchar(10),wubi varchar(10),pinyin varchar(10),bushou varchar(4),bihua integer)";
        db.execSQL(sql);
        /**创建存储文字详情的表*/
          sql = "create table WORD(_id integer primary key autoincrement,id varchar(20),zi varchar(4) unique not null," +
                "py varchar(10),wubi varchar(10),pinyin varchar(10),bushou varchar(4),bihua integer,jijie text," +
                  "xiangjie text)";
          db.execSQL(sql);
          /*创建存储成语的表*/
        sql = "create table CHENGYU(_id integer primary key autoincrement,name varchar(10) unique not null,pinyin varchar(10)" +
                ",jbsy text,xxsy text,chuchu text,liju text,jyc text,fyc text)";
        db.execSQL(sql);
        /*创建收藏文字的表*/
        sql  = "create table COLLWORD(_id integer primary key autoincrement,zi varchar(4) unique not null)";
        db.execSQL(sql);
        /*创建收藏成语的表*/
        sql  = "create table COLLCHENGYU(_id integer primary key autoincrement,name varchar(10) unique not null)";
        db.execSQL(sql);


    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
